//
//  YCOrderMealTableViewCell.m
//  lianganyuchu
//
//  Created by iMac on 17/2/28.
//  Copyright © 2017年 杭州桑缇电子商务有限公司. All rights reserved.
//

#import "YCOrderMealTableViewCell.h"

@interface YCOrderMealTableViewCell()
{
    UIView *m_itemView;
}
@end
@implementation YCOrderMealTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    [self.label1 setFont:[UIFont LightFontOfSize:14]];
    [self.label2 setFont:[UIFont LightFontOfSize:16]];
    [self.label3 setFont:[UIFont LightFontOfSize:16]];
    [self.labExpress setFont:[UIFont LightFontOfSize:15]];
    [self.labTotal setFont:[UIFont LightFontOfSize:15]];
    
    [self.label1 setTextColor:TEXT_LIGHT];
    [self.label2 setTextColor:TEXT_DEEP];
    [self.label3 setTextColor:MAIN_COLOR];
    [self.labExpress setTextColor:TEXT_LIGHT];
    [self.labTotal setTextColor:MAIN_COLOR];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)bindWith:(OrderTable *)order
{
    CGFloat width=kMainScreen_Width-2*kDistance;
    [self.backView addShadowWith:CGSizeMake(width, 140+order.items.count*50)];
    
    if (m_itemView==nil&&order.items.count>0) {
        m_itemView=[[UIView alloc]initWithFrame:CGRectMake(0, 40, W(self.backView), order.items.count*50)];
        for (int i=0; i<order.items.count; i++) {
            ItemTable *item=order.items[i];
            ItemView *view=[[ItemView alloc]initWithFrame:CGRectMake(0, i*50, W(m_itemView), 50)];
            [view bindWith:item];
            [m_itemView addSubview:view];
            
            [m_itemView.layer addSublayer:getLine(kDistance, W(m_itemView)-kDistance, (i+1)*50, (i+1)*50, LINE_COLOR)];
        }
    }
    [self.lineView1 setHidden:YES];
    [self.backView addSubview:m_itemView];
    
    
    [self.labExpress setText:[NSString stringWithFormat:@"￥%@",order.express]];
    [self.labTotal setText:[NSString stringWithFormat:@"￥%@",order.total]];
    
    
}


@end
